package demo1;

public class ClassDatalnterlmpl1 implements ClassDatalnter{
    private Student[] students;
    public ClassDatalnterlmpl1(Student[] students) {
        this.students = students;
    }

    @Override
    public void printAllStudentInfos() {
        System.out.println("全班学生的信息如下：");
        for (int i = 0; i < students.length; i++) {
            Student s = students[i];
            System.out.println(s.getName()+"\t"+s.getSex()+"\t"+s.getScore());
        }
    }

    @Override
    public void printAverageScore() {
        double sum = 0;
        for (int i = 0; i < students.length; i++) {
            Student s = students[i];
            sum += s.getScore();
        }
        double avg = sum/students.length;
        System.out.println("班级的平均分为："+avg);
    }
}
